Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preallocate GPU interpolant #75

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Preallocate GPU interpolant #75

wants to merge 3 commits into from

Conversation

Sbozzolo
Copy link
Member

@Sbozzolo Sbozzolo commented Jul 11, 2024

Adapt allocates new arrays on the GPU. With this PR, I change Adapt to be in place.

This change is trickier than it seems: there is need to move data from the CPU to the GPU when creating a new spline.

target_space,
coordinates,
extrapolation_bc,
zeros(target_space),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use adapt here?

@Sbozzolo Sbozzolo force-pushed the gb/gpuitp branch 2 times, most recently from 43e478a to ffca901 Compare July 23, 2024 08:50
The interpolants we in `Interpolations.jl` are described by two arrays:
the knots and the coeffs. When `Adapt` is called on these interpolants,
CuArrays are allocated on the GPU. For large data, this is inefficient.

In this commit, I add a system to avoid these allocations. This is
accomplished by add a dictionary to `InterpolationsRegridder`. This
dictionary has keys that identify the size of the knots and coefficients
and values the adapted splines. When `regrid` is called, we check if we
have already allocated some suitable space in this dictionary, if not,
we create a new spline, if we do, we write in place.

This removes GPU allocations in the hot path (ie, the regridder is used
in a time evolution with always the same data and dimensions), while
also keeping the flexibility of reusing the same regridder with any
input data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants